<%--
    Document   : process
    Created on : Apr 7, 2011, 10:25:35 AM
    Author     : Muhammad Anis
--%>
<%@page import="java.util.List"%>
<%@page import="system.chatbetweenfriend"%>
<%@page import="tools.commandProcessor"%>
<%@page import="user.user"%>
<%@page import="tools.dbconnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="tools.writer" %>
<jsp:useBean id="chatbeetwenfriend" class="system.chatbetweenfriend" scope="application" />
<%

            String task = request.getParameter("task");
            if (task != null) {
                dbconnector db = new dbconnector(out);
                user currentuser = (user) session.getAttribute("currentuser");
                if(task.equals("addchatfriend")){                    
                    String username = request.getParameter("username");
                    currentuser.addChatFriend(username);
                    chatbeetwenfriend.addChatFriend(currentuser.username, username);
                    session.setAttribute("currentuser", currentuser);
                } else if(task.equals("updatechattab")){
                    List<String> temp = currentuser.isUpdateFriend(chatbeetwenfriend.getFriendChatWith(currentuser.username));
                    //trus print seluruh teman dari awal
                    currentuser.printAllChatTab(out);
                    session.setAttribute("currentuser", currentuser);
                }

            } else {
                writer.redirect("../index.jsp", out);
            }
%>